package com.jic.manager.impl;

import com.jic.common.base.vo.Page;
import com.jic.common.base.vo.PageResult;
import com.jic.manager.entity.SysRoleLog;
import com.jic.manager.mapper.SysRoleLogMapper;
import com.jic.manager.service.SysRoleLogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 
 * @author : 
 * @email : 
 * @since : 2020-02-28 06:28:07
 * @version : v1.0.0
 */
@Service
public class SysRoleLogServiceImpl implements SysRoleLogService {

    @Resource
    private SysRoleLogMapper sysRoleLogMapper;

    @Override
    public long insert(SysRoleLog sysRoleLog) {
        long flag = sysRoleLogMapper.insert(sysRoleLog);
        return flag;
    }

    @Override
    public long delete(Long id) {
        return sysRoleLogMapper.delete(id);
    }

    @Override
    public long update(SysRoleLog sysRoleLog) {
        return sysRoleLogMapper.update(sysRoleLog);
    }

    @Override
    public SysRoleLog queryByPrimaryKey(Long id){
        return sysRoleLogMapper.queryByPrimaryKey(id);
    }

    @Override
    public List<SysRoleLog> query(SysRoleLog sysRoleLog){
        return sysRoleLogMapper.query(sysRoleLog);
    }

    @Override
    public PageResult<SysRoleLog> queryPage(SysRoleLog sysRoleLog, Page pageQuery) {
        //计算下标
        int startIndex = (pageQuery.getStart() - 1) * pageQuery.getLimit();
        List<SysRoleLog> list = sysRoleLogMapper.queryPage(startIndex, pageQuery.getLimit(), sysRoleLog);
        long count = sysRoleLogMapper.queryPageCount(sysRoleLog);
        PageResult pageResult = new PageResult();
        pageResult.setRows(list);
        pageResult.setTotal(count);
        return pageResult;
    }
}